package com.spring;

import com.spring.pojo.Order;
import com.spring.pojo.User;
import com.spring.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringDemo {
    public static void main(String[] args) {
        // 获取到Spring的核心对象
        ApplicationContext ctx = new ClassPathXmlApplicationContext("application-context.xml");
        Object obj = ctx.getBean("person");
        System.out.println(obj);
        Object obj2 = ctx.getBean("person2");
        System.out.println(obj2);

    }
    public static void demo2(){
        // 获取到Spring的核心对象
        ApplicationContext ctx = new ClassPathXmlApplicationContext("application-context.xml");
        Object obj = ctx.getBean("order");
        System.out.println(obj);
    }
    public static void demo1(){
        // 获取到Spring的核心对象
        ApplicationContext ctx = new ClassPathXmlApplicationContext("application-context.xml");
        UserService userService = (UserService) ctx.getBean("userService");
        User user = userService.getById(1123);
        System.out.println(user);
    }
}
